/**
 * 
 */
package com.taobao.wolfwolf.hibernate.service.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.ProductDao;
import com.taobao.wolfwolf.hibernate.pojo.Product;
import com.taobao.wolfwolf.hibernate.service.ProductService;
import com.taobao.wolfwolf.util.HqlParam;

/**
 * @author Tux
 *
 * 创建时间: 2011-5-20 上午09:54:26
 */
public class ProductServiceImpl extends BaseServiceImpl implements ProductService {
	private ProductDao pdao;

	public List<Product> findAll() {
		try {
			return pdao.findAll();
		} catch(Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public Product findById(int id) {
		try {
			return pdao.findById(id);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findById(int id)");
		}
		return null;
	}
	
	@Override
	public Product findById(boolean lazy, int id) {
		try {
			return pdao.findById(lazy, id);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("延迟加载获取商品出错");
		}
		return null;
	}

	public List<Product> findByName(String name) {
		try {
			return pdao.findByName(name);
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findByName(String name)");
		}
		return null;
	}

	public long getTotal()  {
		try {
			return pdao.getTotal();
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at getTotal()");
		}
		return -1;
	}

	public List<Product> paging(int page, int limit)  {
		try {
			return pdao.paging(page, limit);
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at paging(int page, int limit)");
		}
		return null;
	}

	/**
	 * @return the pdao
	 */
	public ProductDao getPdao() {
		return pdao;
	}

	/**
	 * @param pdao the pdao to set
	 */
	public void setPdao(ProductDao pdao) {
		this.pdao = pdao;
	}

	public List<Product> findByPinyin(String abbr) {
		try {
			return pdao.findByPinyin(abbr);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findByPinyin(String abbr)");
		}
		return null;
	}

	@Override
	public List<Product> paging(int page, int limit, List<HqlParam> param) {
		try {
			return pdao.paging(page, limit, param);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at pagingByPropery(int page, int limit, Map<String, String> param)");
		}
		return null;
	}

	@Override
	public long getTotal(List<HqlParam> param) {
		try {
			return pdao.getTotal(param);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at getTotal(List<HqlParam> param)");
		}
		return -1;
	}

	@Override
	public Product findByNumIId(long num_iid) {
		try {
			return pdao.findByNumIId(num_iid);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("按iid查找时出错");
		}
		return null;
	}

	@Override
	public int removeAll() {
		try {
			pdao.removeAll();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("删除全部商品时出错");
			return -1;
		}
		return 1;
	}

	@Override
	public Integer getMaxId() {
		try {
			return pdao.getMaxId();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("获取商品最大id出错");
		}
		return null;
	}
}
